import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import Login from '../views/login/Login.vue'
import Register from '../views/login/Register.vue'
import ChatView from '@/views/ChatView.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: HomeView,
    children: [
      {
        path: 'system',
        name: 'System',
        meta: { title: '系统管理' },
        children: [
          {
            path: 'user',
            name: 'User',
            component: () => import('@/views/system/User.vue'),
            meta: { title: '用户管理' }
          },
          {
            path: 'role',
            name: 'Role',
            component: () => import('@/views/system/Role.vue'),
            meta: { title: '角色管理' }
          }
        ]
      },
      {
        path: 'monitor',
        name: 'Monitor',
        meta: { title: '系统监控' },
        children: [
          {
            path: 'service',
            name: 'Service',
            component: () => import('@/views/monitor/Service.vue'),
            meta: { title: '服务监控' }
          },
          {
            path: 'log',
            name: 'Log',
            component: () => import('@/views/monitor/Log.vue'),
            meta: { title: '日志管理' }
          }
        ]
      },
      {
        path: 'tools',
        name: 'Tools',
        meta: { title: '系统工具' },
        children: [
          {
            path: 'codegen',
            name: 'CodeGen',
            component: () => import('@/views/tools/CodeGen.vue'),
            meta: { title: '代码生成' }
          },
          {
            path: 'apidoc',
            name: 'ApiDoc',
            component: () => import('@/views/tools/ApiDoc.vue'),
            meta: { title: '接口文档' }
          }
        ]
      },
      {
        path: 'demo',
        name: 'Demo',
        meta: { title: '实例演示' },
        children: [
          {
            path: 'demo1',
            name: 'Demo1',
            component: () => import('@/views/demo/Demo1.vue'),
            meta: { title: '演示1' }
          },
          {
            path: 'demo2',
            name: 'Demo2',
            component: () => import('@/views/demo/Demo2.vue'),
            meta: { title: '演示2' }
          },
          {
            path: 'chart',
            name: 'Chart',
            component: () => import('@/views/demo/ChartDemo.vue'),
            meta: { title: '折线图组件' }
          },
          {
            path: 'bar-chart',
            name: 'BarChart',
            component: () => import('@/views/demo/BarChartDemo.vue'),
            meta: { title: '柱状图组件' }
          },
          {
            path: 'bar-chart-test',
            name: 'BarChartTest',
            component: () => import('@/views/demo/BarChartTest.vue'),
            meta: { title: '柱状图测试' }
          },
          {
            path: 'sortable-list',
            name: 'SortableList',
            component: () => import('@/views/demo/SortableListDemo.vue'),
            meta: { title: '排序列表组件' }
          },
          {
            path: 'china-map',
            name: 'ChinaMap',
            component: () => import('@/views/demo/ChinaMapDemo.vue'),
            meta: { title: '中国地图组件' }
          },
          {
            path: 'china-flow-map',
            name: 'ChinaFlowMap',
            component: () => import('@/views/demo/ChinaFlowMapDemo.vue'),
            meta: { title: '中国地图飞线图' }
          },
          {
            path: 'file-upload',
            name: 'FileUploadDemo',
            component: () => import('@/views/demo/FileUploadDemo.vue'),
            meta: { title: '文件上传组件' }
          },
          {
            path: 'smart-table',
            name: 'SmartTableDemo',
            component: () => import('@/views/demo/SmartTableDemo.vue'),
            meta: { title: '智能表格组件' }
          }
        ]
      },
      {
        path: 'chat',
        name: 'Chat',
        component: ChatView,
        meta: { title: 'AI对话', icon: 'ChatDotRound' }
      },
      {
        path: 'file-chat',
        name: 'FileChat',
        component: () => import('@/views/FileChat.vue'),
        meta: { title: '文件对话', icon: 'Document' }
      },
      {
        path: 'short-link',
        name: 'ShortLink',
        component: () => import('@/views/ShortLinkView.vue'),
        meta: { title: '短链接管理', icon: 'Link' }
      },
      {
        path: 'shop',
        name: 'Shop',
        meta: { title: '购物商城' },
        children: [
          {
            path: 'product-add',
            name: 'ProductAdd',
            component: () => import('@/views/shop/ProductAdd.vue'),
            meta: { title: '新增商品' }
          },
          {
            path: 'products',
            name: 'ProductList',
            component: () => import('@/views/shop/ProductList.vue'),
            meta: { title: '商品列表' }
          },
          {
            path: 'product/:id',
            name: 'ProductDetail',
            component: () => import('@/views/shop/ProductDetail.vue'),
            meta: { title: '商品详情' }
          },
          {
            path: 'cart',
            name: 'Cart',
            component: () => import('@/views/shop/Cart.vue'),
            meta: { title: '购物车' }
          }
        ]
      },
      {
        path: 'delivery',
        name: 'Delivery',
        component: () => import('@/views/delivery/DeliveryMain.vue'),
        meta: { title: '校园快送' }
      }
    ]
  },
  { path: '/login', name: 'Login', component: Login },
  { path: '/register', name: 'Register', component: Register },
];

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
})

export default router
